#ifndef SWP_RESOURCE_GRAPHIC_ITEM_CONTENT_H
#define SWP_RESOURCE_GRAPHIC_ITEM_CONTENT_H

#include "swpresourcegraphicitem.h"

#include <igraphicitemcontent.h>

#include <QtGui/QGraphicsRectItem>

QT_BEGIN_NAMESPACE
class QGraphicsSimpleTextItem;
QT_END_NAMESPACE

namespace swp
{

class SwpEntityGraphicItemContent : public QGraphicsRectItem,
    public core::IGraphicItemContent
{
public:
    SwpEntityGraphicItemContent(const QString& entityType,
        const QString& entityName, QGraphicsItem* parent = 0);
    ~SwpEntityGraphicItemContent();

    void setEntityName(const QString& entityName);
    QString entityName() const;

    QString entityType() const;

    // IGraphicItemContent
    QGraphicsItem* graphicsItem() const;
    void drawThumbnail(QPainter& painter, const QRectF& boundingRect);
    QRectF croppedBoundingRect() const;
    void recheckIfFits();
    void setPalette(const core::Palette* const palette);

    // ISerializable
    bool doActionForProperty(const QString& property,
        const QVariantList& value, const core::SerializationEngine& helper);
    void deserializationFinished(bool ok);
    QHash<QString, QVariantList> serializationData(
        const core::SerializationEngine& helper) const;

    QRectF boundingRect() const;

private:
    void refresh();
    void relayout();
    void reorganize(int eWidth, int tWidth, bool refresh = true);

private:
    QString m_type;
    QString m_entity;
    QGraphicsSimpleTextItem* m_typeItem;
    QGraphicsSimpleTextItem* m_entityItem;
    bool m_cropped;
};

} // namespace swp

#endif
